//配置路由的文件
import Vue from 'vue'
import VueRouter from 'vue-router'
// 使用插件
Vue.use(VueRouter)

// 引入路由组件
// 所有的一级路由
import Home from '../pages/Home'
import Login from '../pages/Login'
import Register from '../pages/Register'
import Search from '../pages/Search'
import SysLogin from '../pages/SysLogin'
import Paimai from '../pages/Paimai'
import Inform from '../pages/Inform'
import Word from '../pages/Word'
import About from '../pages/About'
import GoodsInfrom from '../pages/GoodsInfrom'
// 拍卖步骤路由导入
import Process1 from '../pages/Process1'
import Process2 from '../pages/Process2'
import Process3 from '../pages/Process3'
import Process4 from '../pages/Process4'
import Process5 from '../pages/Process5'
import Process6 from '../pages/Process6'
import Process7 from '../pages/Process7'
import Cooperation from '../pages/Cooperation'
// 用户信息导入
import Layout from '../pages/Layout'
// 系统后台信息管理
import Sysout from '../pages/Sysout'
// 二级路由
// 用户后台二级路由
import LayoutShouye from '../pages/LayoutShouye'
import UserSubmit from '../pages/UserSubmit'
import UserAbout from '../pages/UserAbout/index'
import UserMessage from '../pages/UserMessage/index'
import UserSafe from '../pages/UserSafe/index'
// 管理员后台二级路由
import SysManagegoods from '../pages/SysManagegoods/index'
import SysManageusers from '../pages/SysManageusers/index'
import SysManagenews from '../pages/SysManagenews/index'
import SysoutShouye from '../pages/SysoutShouye'
// 用户后台三级路由
import UserOrder from '../pages/UserAbout/UserOrder'
import UserCollect from '../pages/UserAbout/UserCollect'
import UserAdvert from '../pages/UserAbout/UserAdvert'
import UserInfo from '../pages/UserMessage/UserInfo'
import UserUpdateinfo from '../pages/UserMessage/UserUpdateinfo'
import UserLoginpsd from '../pages/UserSafe/UserLoginpsd'
import UserPaypsd from '../pages/UserSafe/UserPaypsd'
import UserJingpai from '../pages/UserAbout/UserJingpai'
import UserReason from '../pages/UserAbout/UserReason'
import UserMoney from '../pages/UserMessage/UserMoney'
import UsermoneyChange from '../pages/UserMessage/UserMoneyChange'
// 管理员后台三级路由
import SysPubgoods from '../pages/SysManagegoods/SysPubgoods'
import SysMsubgoods from '../pages/SysManagegoods/SysMsubgoods'
import SysMpubgoods from '../pages/SysManagegoods/SysMpubgoods'
import SysMorder from '../pages/SysManagegoods/SysMorder'
import SysCart from '../pages/SysManagegoods/SysCart'
import SysGoods from '../pages/SysManagegoods/SysGoods'
import SysPubnews from '../pages/SysManagenews/SysPubnews'
import SysMnews from '../pages/SysManagenews/SysMnews'
import SysMadvert from '../pages/SysManagenews/SysMadvert'
import SysMadmin from '../pages/SysManageusers/SysMadmin'
import SysMusers from '../pages/SysManageusers/SysMusers'

// 先把VueRouter原型对象的push先保存一份
let originPush = VueRouter.prototype.push
let originReplace = VueRouter.prototype.replace

// 重写push|replace
// 第一个参数：告诉原来push方法，往哪里跳转
// 第二个参数：成功的回调
// 第三个参数：失败的回调
VueRouter.prototype.push = function(loction,resolve,reject){
    if(resolve&&reject){
        originPush.call(this,loction,resolve,reject)
    }else{
        originPush.call(this,loction,()=>{},()=>{})
    }
}
VueRouter.prototype.replace = function(loction,resolve,reject){
    if(resolve&&reject){
        originReplace.call(this,loction,resolve,reject)
    }else{
        originReplace.call(this,loction,()=>{},()=>{})
    }
}

// 配置路由
export default new VueRouter({
    // 配置路由信息
    routes: [
        {
            path:'/sysout',
            component:Sysout,
            meta:{
                show:false,//针对Footer的显示与隐藏
            },
            children:[
                {
                    path:'sysoutshouye',
                    component:SysoutShouye
                },
                {
                    path:"sysmanagegoods",
                    component:SysManagegoods,
                    redirect:'sysmanagegoods/syspubgoods',
                    children:[
                        {
                            path:'syspubgoods',
                            component:SysPubgoods
                        },
                        {
                            path:'sysmsubgoods',
                            component:SysMsubgoods
                        },
                        {
                            path:'sysmorder',
                            component:SysMorder
                        },
                        {
                            path:'sysmpubgoods',
                            component:SysMpubgoods
                        },
                        {
                            path:'syscart',
                            component:SysCart
                        },
                        {
                            path:'sysgoods',
                            component:SysGoods
                        }
                    ]
                },
                {
                    path:"sysmanageusers",
                    component:SysManageusers,
                    redirect:'sysmanageusers/sysmadmin',
                    children:[
                        {
                            path:'sysmadmin',
                            component:SysMadmin
                        },
                        {
                            path:'sysmusers',
                            component:SysMusers
                        },
                    ]
                },
                {
                    path:"sysmanagenews",
                    component:SysManagenews,
                    redirect:'sysmanagenews/syspubnews',
                    children:[
                        {
                            path:'syspubnews',
                            component:SysPubnews
                        },
                        {
                            path:'sysmnews',
                            component:SysMnews
                        },
                        {
                            path:'sysmadvert',
                            component:SysMadvert
                        }
                    ]
                }
            ]
        },
        {
            path:'/layout',
            component:Layout,
            meta:{
                show:false,//针对Footer的显示与隐藏
            },
            children:[
                {
                    path:"layoutshouye",
                    component:LayoutShouye
                },
                {
                    path:"usersubmit",
                    component:UserSubmit
                },
                {
                    path:"userabout",
                    component:UserAbout,
                    redirect:'userabout/userorder',
                    children:[
                        {
                            path:'userjingpai',
                            component:UserJingpai
                        },
                        {
                            path:'userorder',
                            component:UserOrder
                        },
                        {
                            path:'useradvert',
                            component:UserAdvert
                        },
                        {
                            path:'usercollect',
                            component:UserCollect
                        },
                        {
                            path:'userreason',
                            component:UserReason
                        },
                    ]
                },
                {
                    path:"usermessage",
                    component:UserMessage,
                    redirect:'usermessage/userinfo',
                    children:[
                        {
                            path:'userinfo',
                            component:UserInfo
                        },
                        {
                            path:'userupdateinfo',
                            component:UserUpdateinfo
                        },
                        {
                            path:'usermoney',
                            component:UserMoney
                        },
                        {
                            path:'usermoneychange',
                            component:UsermoneyChange
                        }
                    ]
                },
                {
                    path:"usersafe",
                    component:UserSafe,
                    redirect:'usersafe/userloginpsd',
                    children:[
                        {
                            path:'userloginpsd',
                            component:UserLoginpsd
                        },
                        {
                            path:'userpaypsd',
                            component:UserPaypsd
                        }
                    ]
                }
            ]
        },
        {
            path:'/cooperation',
            component:Cooperation,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process2',
            component:Process2,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process3',
            component:Process3,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process4',
            component:Process4,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process5',
            component:Process5,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process6',
            component:Process6,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process7',
            component:Process7,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/process1',
            component:Process1,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/home',
            component:Home,
            meta:{
                show:true,//针对Footer的显示与隐藏
            }
        },
        {
            path:'/login',
            component:Login,
            meta:{
                show:false,
            }
        },
        {
            path:'/register',
            component:Register,
            meta:{
                show:false,
            }
        },
        {
            path:'/sysLogin',
            component:SysLogin,
            meta:{
                show:false,
            }
        },
        {
            path:'/paimai',
            component:Paimai,
            meta:{
                show:true,
            },
        },
        {
            path:'/goodsInfrom/:id',
            component:GoodsInfrom,
            meta:{
                show:false,
            },
        },
        {
            path:'/inform',
            component:Inform,
            meta:{
                show:true,
            }
        },
        {
            path:'/word',
            component:Word,
            meta:{
                show:true,
            }
        },
        {
            path:'/about',
            component:About,
            meta:{
                show:true,
            }
        },
        {
            path:'/search/:keyword?',
            component:Search,
            meta:{
                show:true,
            },
            name:'search'
        },
        // 重定向，在项目跑起来的时候，访问/，立马让他定向到首页
        {
            path:'*',
            redirect:'/home'
        }

    ]
})